package work20241226;

/**
 * @author zdl
 * @date 2024/12/26
 */
public class Demo9 {
    public static void main(String[] args) {
        //9. 编写一个程序，创建一个守护线程和一个用户线程，观察它们的行为。
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println("非守护线程" + i);
                }
            }
        });
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println("守护线程:" + i);
                }
            }
        });
        t2.setDaemon(true);
        t1.start();
        t2.start();
    }
}
